package com.nightwalkbuddy.service;

import android.content.Context;

import com.nightwalkbuddy.dto.User;

/**
 * interface class
 * @author Jones, Brandon
 * 
 */

public interface IUserService {

	/**
	 * Login the user with the given username and password online via HTTP
	 * networking fetch user info from Web site for authentication
	 * 
	 * @param username
	 *            the user's entered username.
	 * @param password
	 *            the user's entered password.
	 * @return String NOTOK for invalid input, NOTGOOD for failed input,
	 *         returned emergency contact phone number and emergency message if
	 *         ok
	 * @throws Exception Any error in the underlying persistence mechanism
	 */
	public String login(String username, String password) throws Exception;

	/**
	 * Login the user with the given username and password offline fetch user
	 * info from SQLite db for authentication
	 * @param context the context it is originated
	 * @param username entered username
	 * @param password entered password
	 * @return boolean true login success and vice versa
	 * @throws Exception Any error in the underlying persistence mechanism
	 */
	public boolean offlineLogin(Context context, String username, String password)
			throws Exception;

	/**
	 * Save the given user.
	 * 
	 * @param httpResponse
	 *            Delimited string HttpReponse from web authentication
	 * @throws Exception
	 *             Any error in the underlying persistence mechanism.
	 */
	public void save(Context context, String httpResponse) throws Exception;

	/**
	 * Retrieve the given user.
	 * 
	 * @param context
	 *            the context where the HttpResponse is from
	 * @param username
	 *            the username that belongs to the user to retrieve.
	 * @return the user retrieved
	 * @throws Exception
	 *             if the user does not exist, or if there is an underlying
	 *             error in the persistence mechanism.
	 */
	public User getUser(Context context, String username) throws Exception;

}
